#include "ActionApiBase.h"
#include "global.h"
#include "Md5.h"
#include "util.h"



const char* ActionApiBase::ToString(std::int32_t err)
{
    switch(err)
    {
    }
    return "";
}

std::string ActionApiBase::GenTransId()
{
    char sztmp[56] = { 0 };
    static std::uint32_t s_utransseq = 0; 
    while (!(s_utransseq = ++s_utransseq % std::numeric_limits<unsigned int>::max()))
    {
    }
    ::snprintf(sztmp, sizeof(sztmp), "%u_%llu_%u", TGlobal::_svid, time(NULL), s_utransseq);

    return std::string(sztmp);
}

std::string ActionApiBase::GenTransMd5()
{
    static std::uint64_t index = 0;
    std::stringstream ss;
    // 当前时间 + 唯一服务id + 当前服务序号
    ss << CTools::GetUnixTimeMs() << ":" << TGlobal::_svid << ":" << index++;
    // 转MD5 屏蔽 trans 细节
    return MD5(ss.str()).toStr();
}

const std::string& ActionApiBase::GameProvider()
{
    static const std::string kb = "kb";
    return kb;
}
























